//Headers needed
#include <f32file.h> //RFs
#include <d32dbms.h>  //RDbNamedDatabase,RDbView
#include <bautils.h> //RFs

#ifndef _MYDB_H_
#define _MYDB_H_

//database name
_LIT(KSettDatabaseName, "expenses.db");
 
// database column names
_LIT(NSettCol0, "index");
_LIT(NSettCol1, "note");
_LIT(NSettCol2, "date");
_LIT(NSettCol3, "exp");
_LIT(NSettCol4, "cat");
 
// database table name
_LIT(KSettDesTable, "DesTable");


class CMyDBClass : public CBase
{
public : 
    void ConstructL();
    ~CMyDBClass();
    static CMyDBClass* NewL();
public:
	TBool UpdateDatabaseL(const TDesC& aNote, TInt& aCat,TReal32& aExp,TInt64& aDate);
    void UpdateDatabaseL(const TDesC& aName, const TInt32 aValue);
    void ReadDbItemsL();
    TBool ReadDbItemsL(const TDesC& aNote, TInt& aCat,TReal32& aExp,TInt64& aDate);
    TBool ReadDbItemsL(const TDesC& aName, TInt32 &aValue);
    
private:
	void CreateTableL();
	void OpenTableLC(const TDesC& aTableName);
	TBool FindInTableL(const TDesC& aName);
private:
    RDbNamedDatabase iItemsDatabase;
    RFs iFsSession;
    TFileName DBFileName;
	TFileName QueryBuffer;
	RDbView MyView;
	
};

#endif
